package main

import (
	"context"
	"fmt"

	"github.com/micro/go-micro/v2"
	"github.com/micro/go-micro/v2/registry"
	consul2 "github.com/micro/go-plugins/registry/consul/v2"

	user "user_srv/proto"
)

func main() {
	//注册中心
	consul := consul2.NewRegistry(
		registry.Addrs("127.0.0.1:8500"),
	)

	service := micro.NewService(
		micro.Name("user.client.api"),
		micro.Version("latest"),
		//添加注册中心
		micro.Registry(consul),
		//绑定链路追踪
		//micro.WrapClient(opentracing2.NewClientWrapper(opentracing.GlobalTracer())),
	)
	userService := user.NewUserSrvService("user.srv", service.Client())

	response, err := userService.AddUser(context.TODO(), &user.ResponseUserInfo{
		Account:     "14",
		UserName:    "142",
		PassWord:    "1253",
		Departments: "1532",
		Email:       "1523",
		Status:      1,
		Role:        1,
		Addr:        "1325",
		Mobile:      "51",
	})
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(response)
	service.Run()

}
